home *** CD-ROM | disk | FTP | other *** search
- // $Id: tree.vsl,v 1.2 1995/05/17 13:40:01 zeller Exp $
- // Draw trees
-
- // Copyright (C) 1993 Technische Universitaet Braunschweig, Germany.
- // Written by Andreas Zeller (zeller@ips.cs.tu-bs.de).
- //
- // This file is part of the NORA Library.
- //
- // The NORA Library is free software; you can redistribute it and/or
- // modify it under the terms of the GNU Library General Public
- // License as published by the Free Software Foundation; either
- // version 2 of the License, or (at your option) any later version.
- //
- // The NORA Library is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- // See the GNU Library General Public License for more details.
- //
- // You should have received a copy of the GNU Library General Public
- // License along with the NORA Library -- see the file COPYING.LIB.
- // If not, write to the Free Software Foundation, Inc.,
- // 675 Mass Ave, Cambridge, MA 02139, USA.
- //
- // NORA is an experimental inference-based software development
- // environment. Contact nora@ips.cs.tu-bs.de for details.
-
- #include "std.vsl"
- #include "slopes.vsl"
-
- // Version
- tree_version() = "$Revision: 1.2 $";
-
- // Baumfunktionen
-
- // 1. Vertikale Baeume
-
- // Verhaeltnis Hoehe zu Breite (hier: (1:10))
-
- treeheight(width) = vspace(square(width)) / 10;
-
- // branches zeichnet die Verbindungen von der Wurzel zu den Soehnen.
- // branches gibt einen Kasten der Breite hroot * 2 und der Hoehe height
- // zurueck.
- // Von der Mitte der oberen Kante von hsum + box/2 hin zur Mitte der
- // oberen Kante des Kastens ist eine Linie gezogen.
-
- vbranch(height, hroot, hsum, hbox2) =
- ( height &
- if hsum & hbox2 < hroot then
- // box in linker Haelfte
- hsum & hbox2 & rise() & hroot
- elsif hsum & hbox2 > hroot then
- // box in rechter Haelfte
- hroot & fall() & hspace(hroot * 2 - hsum - hbox2)
- else
- // box in der Mitte
- hcenter(vrule())
- fi
- );
-
- vbranches(height, hroot, hsum, box) =
- vbranch(height, hroot, hsum, hspace(box)/2);
-
- vbranches(height, hroot, hsum, box, ...) =
- vbranches(height, hroot, hsum, box)
- ^ vbranches(height, hroot, hsum & hspace(box), ...);
-
-
- // vtree(soehne...) verbindet eine Wurzel mit Soehnen. Die Kanten
- // enden jeweils in der Mitte der oberen Kante des Sohnes.
-
- _vtree(align, ...) =
- vbranches(treeheight(hspace(align)), hspace(align)/2, 0, ...)
- | hcenter(align);
-
- vtree(root) = root;
- vtree(root, ...) =
- hcenter(root)
- | _vtree(halign(...), ...);
-
-
-
- // 2. Horizontale Baeume
-
- // Das gleiche, nur um 90 Grad gedreht
-
- treewidth(height) = hspace(square(height)) / 10;
-
- hbranch(width, vroot, vsum, vbox2) =
- ( width |
- if vsum | vbox2 < vroot then
- // box in oberer Haelfte
- vsum | vbox2 | rise() | vroot
- elsif vsum | vbox2 > vroot then
- // box in unterer Haelfte
- vroot | fall() | vspace(vroot * 2 - vsum - vbox2)
- else
- // box in der Mitte
- vcenter(hrule())
- fi
- );
-
- hbranches(width, vroot, vsum, box) =
- hbranch(width, vroot, vsum, vspace(box)/2);
-
- hbranches(width, vroot, vsum, box, ...) =
- hbranches(width, vroot, vsum, box)
- ^ hbranches(width, vroot, vsum | vspace(box), ...);
-
- _htree(align, ...) =
- hbranches(treewidth(vspace(align)), vspace(align)/2, 0, ...)
- & vcenter(align);
-
- htree(root) = root;
- htree(root, ...) =
- vcenter(root)
- & _htree(valign(...), ...);
-